define(
		[ "PDUtilDir/util", "PDUtilDir/tool", "PDUtilDir/slidebar", "PDUtilDir/inputSelect", "Date",
			"DateCN", "css!DateCss" ],
		function(Util, Tool, Slidebar, inputSelect) {
			function addSupportInit($scope, $compile){
				return new addSupport($scope, $compile);
			};
			function addSupport($scope, $compile){
				this.$scope = $scope;
				this.$compile = $compile;
			};
			addSupport.fn = addSupport.prototype;
			addSupport.fn.init = function(){
				this.entity = {};
			};
			addSupport.fn.digest = function(){
				 this.$scope.$digest();
			};
			addSupport.fn.run = function() {
				var _this = this;
				_this.init();
				this.slidebars = Slidebar({
					size : 'lg',
					url : getServer()
							+ "/static/app/hotel/hotelPolicy/views/add.html",
					$scope: this.$scope,
					$compile: this.$compile,
					afterLoad : function($Panel) {
						_this.initialization();
					}
				});
			};
			addSupport.fn.initialization = function(){
				this.baseInit();
			};
			
			addSupport.fn.baseInit = function() {
				var _this = this;
				//加载code
				$.ajax({
					url : getServer()
							+ "/flea/hclv/getUUID.htmls",
					method : 'get',
					success : function(data) {
                        if (data.status != 200) {
                            return;
                        }
						_this.entity.code = data.data;
						_this.digest();
					}
				});
				$.ajax({
		    		url:getServer()+"/flea/hclv/hotel/getSelfHotels.htmls",
		    		sync:true,
		    		success:function(data){
                        if (data.status != 200) {
                            return;
                        }
		    			_this.$scope.cache.hotelArray = data;
		    			inputSelect.dropCache();
						inputSelect({
							id : "addHotelName",
							key : {
								id : "id",
								name : "name",
								data : "data",
							},
							data : _this.$scope.cache.hotelArray,
							simpleData : true,
							// 启用文本搜索
							// initData:[initProvice],
							searchAble : false,
							callback : function(id) {
								_this.entity.uuid = id[0];
								_this.$scope.addHotelPolicyForm.uuid.$setViewValue(_this.entity.uuid);
							}
						});
		    		}
		    	});
				$("#startTime").datetimepicker({
					// 设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
					 language : "cn",
		               //输出格式化
		               format : 'yyyy-mm-dd hh:ii:ss',
		               //直接选择‘今天’
		               todayBtn : true,
		               //设置最精确的时间选择视图
		               minView : 'hour',
		               //高亮当天日期
		               todayHighlight : true,
		               //显示“上午”“下午”
		               showMeridian : true,
		               //选择完毕后自动关闭
		               autoclose : true
				});
				$("#endTime").datetimepicker({
					// 设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
					 language : "cn",
		               //输出格式化
		               format : 'yyyy-mm-dd hh:ii:ss',
		               //直接选择‘今天’
		               todayBtn : true,
		               //设置最精确的时间选择视图
		               minView : 'hour',
		               //高亮当天日期
		               todayHighlight : true,
		               //显示“上午”“下午”
		               showMeridian : true,
		               //选择完毕后自动关闭
		               autoclose : true
				});
			};
			addSupport.fn.save = function() {
				var _this = this;
				$.ajax({
                    url : getServer() + "/flea/hclv/hotel/policy/saveOrUpdatePolicy.htmls",
                    data : {
                        "model": JSON.stringify(_this.entity)
                    },
                    success : function(data) {
                        if (data.status != 200) {
                            return;
                        }
                    	_this.$scope.grid.refresh();
                        Util.alert(data.message);
                        _this.slidebars.close();
                    }
				});
			};
			return addSupportInit;
		});